const {
    exec,
    escape
} = require('../db/mysql')

const {
    updateUser
} = require('../services/user')
const { SuccessModel, ErrorModel } = require('../model/ResModel')
// const authData = async (uid, username, cover, describe, province, city, type, phone, wechat, imgdata) => {
//     const createtime = new Date().getTime()
//     let sql = `
//     insert into auth (uid,username,cover,\`describe\`,province,city,type,phone,wechat,imgdata,createtime) values 
//     (${uid},'${username}','${cover}','${describe}','${province}','${city}','${type}',${phone},'${wechat}','${imgdata}',${createtime})
//     `
//     auth = await exec(sql)
//     if (auth.affectedRows > 0) {
//         return '入驻提交成功!'
//     }
// }

async function authUser({
    cover,
    nickName,
    describe,
    city,
    province,
    types,
    weChat,
    phone,
    imgsData,
    auth,
    openId
}) {
    const result = await updateUser({
        cover,
        nickName,
        describe,
        city,
        province,
        types,
        weChat,
        phone,
        imgsData,
        auth,
        openId
    })
    if(result){
        return new SuccessModel()
    }
}

module.exports = {
    authUser
}